package Panels;

import java.awt.Font;
import java.awt.GridBagConstraints;
import java.awt.GridBagLayout;
import java.awt.Insets;
import java.awt.event.MouseEvent;
import java.awt.event.MouseListener;
import javax.swing.JButton;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.plaf.metal.MetalIconFactory;


public class Tab extends JPanel implements MouseListener{
	
	public Tab(String Name){

		setLayout(new GridBagLayout());
		setOpaque(false);
		setVisible(true);
		setFocusable(false);
		setBorder(null);
		
		JButton ExitButton=new JButton(MetalIconFactory.getInternalFrameCloseIcon(16));
		ExitButton.setMargin(new Insets(0,0,0,0));
		ExitButton.setOpaque(false);
		ExitButton.setFocusable(false);
		ExitButton.setBorder(null);
		ExitButton.addMouseListener(this);
		ExitButton.setName(Name);
		
		GridBagConstraints Constraints=new GridBagConstraints();
		Constraints.gridx=0;
		Constraints.gridy=0;
		Constraints.weightx=1;
		
		JLabel TabLabel=new JLabel(Name);
		TabLabel.setFont(new Font("Serif",Font.PLAIN,14));
		add(TabLabel,Constraints);

		Constraints.gridx++;
		Constraints.weightx=0;
		add(ExitButton,Constraints);
	}

	@Override
	public void mouseClicked(MouseEvent Event){
		DatabaseHome.getInstance().RemoveTab(Event.getComponent().getName());
	}

	@Override
	public void mousePressed(MouseEvent e){}

	@Override
	public void mouseReleased(MouseEvent e){}

	@Override
	public void mouseEntered(MouseEvent e){}

	@Override
	public void mouseExited(MouseEvent e){}
	
	
}
